//
//  ListControllerBG.m
//  pa
//
//  Created by HaiJiao Chen on 12-7-30.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "ListControllerBG.h"

@implementation ListControllerBG
@synthesize color1;
@synthesize color2;
@synthesize cellHeight;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
    }
    return self;
}

- (void)dealloc
{
    [color1 release];
    [color2 release];
    [super dealloc];
}

// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
    if (cellHeight > 0)
    {
        CGContextRef g = UIGraphicsGetCurrentContext();
        UIGraphicsPushContext(g);
        int height = self.frame.size.height;
        int num = (height/cellHeight) + 1;
        for (int i = 0; i < num; i++)
        {
            if (i&1)
            {
                CGContextSetFillColorWithColor(g, color2.CGColor);
            }
            else
            {
                CGContextSetFillColorWithColor(g, color1.CGColor);
            }
            CGContextFillRect(g, CGRectMake(0, i*cellHeight, self.frame.size.width, cellHeight));
        }
        UIGraphicsPopContext();
    }
}

@end
